package com.pets.controller;


import com.pets.pojo.CourseManagement;
import com.pets.pojo.EquipmentManagement;
import com.pets.service.ICourseManagementService;
import com.pets.service.IEquipmentManagementService;
import com.pets.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 器材管理 前端控制器
 * </p>
 *
 * @author 小陳同學
 * @since 2024-05-13
 */
@RestController
@RequestMapping("/equipment-management")
@Api(tags = "器材管理")
public class EquipmentManagementController {

    @Autowired
    private IEquipmentManagementService equipmentManagementService;


    @ApiOperation("创建器材")
    @PostMapping
    public Result register(@RequestBody EquipmentManagement equipmentManagement) {
        return equipmentManagementService.register(equipmentManagement);
    }

    @ApiOperation("根据id删除器材")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        return equipmentManagementService.deleteById(id);
    }

    @ApiOperation("修改器材信息")
    @PutMapping("/update")
    public Result update(@RequestBody EquipmentManagement equipmentManagement) {
        return equipmentManagementService.update(equipmentManagement);
    }


    @ApiOperation("查询器材分页集合")
    @GetMapping("/list")
    public Result list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       @ApiParam(value = "器材名称")@RequestParam(required = false) String equipmentName) {
        return equipmentManagementService.selectPage(page, pageSize, equipmentName);
    }

}
